package com.lg.erp.controller.wuwubu;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lg.erp.entity.JsonResult;
import com.lg.erp.entity.wuwuub.CheckProduct;
import com.lg.erp.service.wuwubu.ICheckProductService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

import java.util.List;


/*
* 质量追溯  RestController控制层
* */
@RestController
public class CheckProductController {

    @Autowired
    private ICheckProductService checkProductService;

    @RequestMapping("/check/{current}")
    public JsonResult getCheckProduct(@PathVariable Integer current){
        Page<CheckProduct> page = new Page<>(current, 5);
        IPage<CheckProduct> iPage = checkProductService.getCheckProduct(page);
        return new JsonResult(1 , "ok",iPage);
    }

    @GetMapping("/checkFind")
    public JsonResult checkFind(@RequestParam(value = "id") String id){
        System.out.println("产品id ->"+id);
        List<CheckProduct> checkProduct = checkProductService.checkFindById(id);
        for (CheckProduct t : checkProduct ){
            System.out.println(t.getProductName());
            System.out.println(t.getProductPrice());
            System.out.println(t.getProductBrand());
            System.out.println(t.getProductEnterprise());
            System.out.println(t.getProductLocal());
            System.out.println(t.getProductMaterial());
            System.out.println(t.getProductShelfLife());
            System.out.println(t.getProductQuality());

        }
        return new JsonResult(1,"ok",checkProduct);
    }

    @GetMapping("/checkProduct")
    public JsonResult getCheckProductById(@RequestParam(value = "id") String id){
        System.out.println("产品id ->"+id);
        CheckProduct checkProduct = checkProductService.getCheckProductById(id);

        System.out.println(checkProduct.getProductName());
        System.out.println(checkProduct.getProductPrice());
        System.out.println(checkProduct.getProductBrand());
        System.out.println(checkProduct.getProductEnterprise());
        System.out.println(checkProduct.getProductLocal());
        System.out.println(checkProduct.getProductMaterial());
        System.out.println(checkProduct.getProductShelfLife());
        System.out.println(checkProduct.getProductQuality());

        return new JsonResult(1,"ok",checkProduct);
    }


}
